package cn.credit.loan.service.customer;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.credit.loan.dao.customer.CustomerMapper;
import cn.credit.loan.entity.Customer;

@Service
@Transactional
public class CustomerServiceImpl implements CustomerService {
	//注入
	@Autowired
	private CustomerMapper customerMapper;
	
	/**
	 * 用户基本信息集合列表
	 */
	@Override
	public List<Customer> getCustomerList(Customer customer)throws Exception {
		List<Customer> customerslist=customerMapper.getCustomerList(customer);
		if(customerslist!=null){
			return customerslist;
		}
		return null;
	}
	
	/**
	 * 用户录入个人的基本信息
	 */
	@Override
	public Boolean addCustomer(Customer customer) throws Exception {
		if(customer!=null){
			int num=customerMapper.addCustomer(customer);
			if(num>0){
				return true;
			}
		}
		return false;
	}
	
	/**
	 * 修改用户录入个人基本信息
	 */
	@Override
	public Boolean updateCustomer(Customer customer) throws Exception {
		if(customer!=null){
			int num=customerMapper.updateCustomer(customer);
			if(num>0){
				return true;
			}
		}
		return false;
	}

	/**
	 * 根据客户id查询客户基本信息
	 */
	@Override
	public Customer getCustomerListById(Integer custId) throws Exception {
		Customer customer=customerMapper.getCustomerListById(custId);
		if(custId!=null){
			if(customer!=null){
				return customer;
			}
			
		}
		return null;
	}
	
	/**
	 * 验证
	 */
	@Override
	public Customer getcustomer(Customer customer) throws Exception{
		Customer cust=customerMapper.getcustomer(customer);
		if(cust!=null){
			return cust;
		}
		return null;
	}

}
